package org.springblade.modules.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springblade.modules.system.entity.FlowerType;
import org.springblade.modules.system.entity.Flowers;
import org.springblade.modules.system.mapper.FlowersMapper;
import org.springblade.modules.system.service.FlowersService;
import org.springblade.utils.PageBounds;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FlowersServiceImpl extends ServiceImpl<FlowersMapper, Flowers> implements FlowersService {

	@Override
	public PageBounds<Flowers> showFlowersTable(Flowers flowers, int currentPage, int pageSize) {
		//数据总条数
		final int totalSize = baseMapper.getFlowerCount(flowers);
		PageBounds<Flowers> pageBounds = new PageBounds<>(currentPage, totalSize, pageSize);
        List<Flowers> list = baseMapper.selectByLimitPage(flowers, pageBounds.getOffset(), pageBounds.getPageSize());
        pageBounds.setPageList(list);
		return pageBounds;
	}

	@Override
	public Flowers getFlowerById(Integer id) {
		return baseMapper.getFlowerById(id);
	}

	@Override
	public int updateFlower(Flowers flowers) {
		return baseMapper.updateFlower(flowers);
	}

	@Override
	public int addFlower(Flowers flowers) {
		return baseMapper.addFlower(flowers);
	}

	@Override
	public int delFlower(Integer id) {
		return baseMapper.delFlower(id);
	}

	@Override
	public int deleteFlowers(List<Integer> ids) {
		return baseMapper.deleteFlowers(ids);
	}

	@Override
	public List<FlowerType> selAllFlowerType() {
		return baseMapper.selAllFlowerType();
	}

}
